<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>竞猜设置</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-card layui-col-md12">
				<div class="layui-card-header">
					<i class="fa fa-cog"></i> 竞猜设置
				</div>
				<div class="layui-card-body" pad15>
					<div class="layui-form form-label-w8" lay-filter="">
						
						<div class="layui-form-item">
							<label class="layui-form-label">状态：</label>
							<div class="layui-input-inline">
								<input type="radio" name="info[status]" value="1" title="开启" {if !$info['id'] || $info['status']==1}checked{/if}>
								<input type="radio" name="info[status]" value="0" title="关闭" {if $info['status']==0}checked{/if}>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">开赛前：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[starthour]" lay-verify="required" lay-verType="tips" class="layui-input" value="{$info['starthour']}">
							</div>
							<div class="layui-form-mid">小时开启竞猜</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">猜胜负{:t('积分')}：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[givescore1]" lay-verify="required" lay-verType="tips" class="layui-input" value="{$info['givescore1']}">
							</div>
							<div class="layui-form-mid layui-word-aux">猜胜负猜中奖励积分</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label">猜比分{:t('积分')}：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[givescore2]" lay-verify="required" lay-verType="tips" class="layui-input" value="{$info['givescore2']}">
							</div>
							<div class="layui-form-mid layui-word-aux">猜比分猜中奖励积分</div>
						</div>
						<div id="guess1set_div">
							{php} $guess1setata = json_decode($info['guess1set'],true);if(!$guess1setata) $guess1setata = [['times'=>'','score'=>'','coupon_id'=>'','coupon_name'=>'']];{/php}
							{foreach $guess1setata as $k=>$v}
							<div class="layui-form-item">
								<label class="layui-form-label">{if $k==0}猜胜负额外奖励：{/if}</label>
								<div class="layui-form-mid">猜中</div>
								<div class="layui-input-inline" style="width:70px"><input type="text" name="guess1_times[]" value="{$v['times']}" class="layui-input"></div>
								<div class="layui-form-mid">次，额外赠送</div>
								<div class="layui-input-inline" style="width:70px"><input type="text" name="guess1_score[]" value="{$v['score']}" class="layui-input"></div>
								<div class="layui-form-mid">{:t('积分')},</div>
                 <div class="layui-form-mid">{:t('优惠券')}ID</div>
                <div class="layui-input-inline" style="width:70px"><input type="text" name="guess1_coupon_id[]" value="{$v['coupon_id']}" class="layui-input"></div>
                <input type="hidden" name="guess1_coupon_name[]" value="{$v['coupon_name']}" class="layui-input">
                <div class="layui-form-mid">{:t('优惠券')}名称:<span>{$v['coupon_name']}</span></div>
                <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="showChooseCoupon(this)">选择</button>
								{if $k==0}
								<button class="layui-btn layui-btn-primary" onclick="addguess1set()"><i class="fa fa-plus"></i></button>
								{else}
								<button class="layui-btn layui-btn-primary" onclick="removeguess1set(this)"><i class="fa fa-minus"></i></button>
								{/if}
							</div>
							{/foreach}
						</div>

						
						<div id="guess2set_div">
							{php} $guess2setata = json_decode($info['guess2set'],true);if(!$guess2setata) $guess2setata = [['times'=>'','score'=>'','coupon_id'=>'','coupon_name'=>'']];{/php}
							{foreach $guess2setata as $k=>$v}
							<div class="layui-form-item">
								<label class="layui-form-label">{if $k==0}猜比分额外奖励：{/if}</label>
								<div class="layui-form-mid">猜中</div>
								<div class="layui-input-inline" style="width:70px"><input type="text" name="guess2_times[]" value="{$v['times']}" class="layui-input"></div>
								<div class="layui-form-mid">次，额外赠送</div>
								<div class="layui-input-inline" style="width:70px"><input type="text" name="guess2_score[]" value="{$v['score']}" class="layui-input"></div>
								<div class="layui-form-mid">{:t('积分')},</div>
                 <div class="layui-form-mid">{:t('优惠券')}ID</div>
                <div class="layui-input-inline" style="width:70px"><input type="text" name="guess2_coupon_id[]" value="{$v['coupon_id']}" class="layui-input"></div>
                <input type="hidden" name="guess2_coupon_name[]" value="{$v['coupon_name']}" class="layui-input">
                <div class="layui-form-mid">{:t('优惠券')}名称:<span>{$v['coupon_name']}</span></div>
                <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="showChooseCoupon(this)">选择</button>
								{if $k==0}
								<button class="layui-btn layui-btn-primary" onclick="addguess2set()"><i class="fa fa-plus"></i></button>
								{else}
								<button class="layui-btn layui-btn-primary" onclick="removeguess2set(this)"><i class="fa fa-minus"></i></button>
								{/if}
							</div>
							{/foreach}
						</div>

						{if in_array('wx',$platform)}
						<div class="layui-form-item">
							<label class="layui-form-label">小程序激励广告：</label>
							<div class="layui-input-inline">
								<input type="text" name="info[rewardedvideoad]" class="layui-input" value="{$info['rewardedvideoad']}">
							</div>
							<div class="layui-form-mid layui-word-aux">填写广告位ID 在小程序后台"流量主-广告管理-激励广告"中查找，设置后参与竞猜时必须先看完激励广告视频</div>
						</div>
						{/if}

						<!-- 详情编辑器 -->
						<div class="layui-form-item">
							<label class="layui-form-label">规则说明：</label>
							<div class="layui-input-inline" style="width:500px">
								<script id="guize" name="info[guize]" type="text/plain" style="width:100%;height:500px">{$info.guize}</script>
							</div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label"></label>
							<div class="layui-input-block">
								<button class="layui-btn" lay-submit lay-filter="formsubmit">提 交</button>
							</div>
						</div>
					</div>
					
				</div>
			</div>
		</div>
	</div>
	{include file="public/js"/}
	<script>
	var coupon_id = '';
	var coupon_name = '';
	var coupon = '';
	function showChooseCoupon(obj){
		coupon_name = $(obj).prev().find("span");
		coupon = $(obj).prev().prev();
		coupon_id = $(obj).prev().prev().prev().find("input");
		chooseCouponLayer = layer.open({type:2,title:'选择{:t(\'优惠券\')}',content:"{:url('Coupon/choosecoupon')}",area:['1000px','600px'],shadeClose:true});
	}
	function choosecoupon(res){
		var detail = res;
		coupon_name.text(res.name);
		coupon.val(res.name);
		coupon_id.val(res.id);
	}
	function addguess1set(){
		var html = '';
		html+='<div class="layui-form-item">';
		html+='	<label class="layui-form-label"></label>';
		html+='	<div class="layui-form-mid">猜中</div>';
		html+='	<div class="layui-input-inline" style="width:70px"><input type="text" name="guess1_times[]" value="" class="layui-input"></div>';
		html+='	<div class="layui-form-mid">次，额外赠送</div>';
		html+='	<div class="layui-input-inline" style="width:70px"><input type="text" name="guess1_score[]" value="" class="layui-input"></div>';
		html+='	<div class="layui-form-mid">{:t('积分')}</div>';
		html+='<div class="layui-form-mid">{:t('优惠券')}ID</div>';
    html+=' <div class="layui-input-inline" style="width:70px"><input type="text" name="guess1_coupon_id[]" value="" class="layui-input"></div>';
    html+='<input type="hidden" name="guess1_coupon_name[]" value="" class="layui-input">';
    html+='<div class="layui-form-mid">{:t('优惠券')}名称:<span></span></div>';
    html+='<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="showChooseCoupon(this)">选择</button>';
		html+='	<button class="layui-btn layui-btn-primary" onclick="removeguess2set(this)"><i class="fa fa-minus"></i></button>';
		html+='</div>';
		$('#guess1set_div').append(html);
	}
	function removeguess2set(obj){
		$(obj).parent().remove();
	}
	
	function addguess2set(){
		var html = '';
		html+='<div class="layui-form-item">';
		html+='	<label class="layui-form-label"></label>';
		html+='	<div class="layui-form-mid">猜中</div>';
		html+='	<div class="layui-input-inline" style="width:70px"><input type="text" name="guess2_times[]" value="" class="layui-input"></div>';
		html+='	<div class="layui-form-mid">次，额外赠送</div>';
		html+='	<div class="layui-input-inline" style="width:70px"><input type="text" name="guess2_score[]" value="" class="layui-input"></div>';
		html+='	<div class="layui-form-mid">{:t('积分')}</div>';
		html+='<div class="layui-form-mid">{:t('优惠券')}ID</div>';
    html+=' <div class="layui-input-inline" style="width:70px"><input type="text" name="guess2_coupon_id[]" value="" class="layui-input"></div>';
    html+='<input type="hidden" name="guess2_coupon_name[]" value="" class="layui-input">';
    html+='<div class="layui-form-mid">{:t('优惠券')}名称:<span></span></div>';
    html+='<button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="showChooseCoupon(this)">选择</button>';
		html+='	<button class="layui-btn layui-btn-primary" onclick="removeguess2set(this)"><i class="fa fa-minus"></i></button>';
		html+='</div>';
		$('#guess2set_div').append(html);
	}
	function removeguess2set(obj){
		$(obj).parent().remove();
	}
	var ueditor = UE.getEditor('guize');
	layui.form.on('submit(formsubmit)', function(obj){
		var field = obj.field
		field['info[guize]'] = ueditor.getContent();
		var index = layer.load();
		$.post('',field,function(data){
			layer.close(index);
			dialog(data.msg,data.status);
			if(data.status==1){
				setTimeout(function(){
					location.href = location.href
				},1000)
			}
		})
	})
  </script>
	{include file="public/copyright"/}
</body>
</html>